package com.lhoverc.mapper;

import com.lhoverc.pojo.VO.TodayApplyVO;
import com.lhoverc.pojo.entity.VisitorEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: LiCheng
 * @CreateTime: 2025-04-14
 * @Description:
 * @Version: 1.0
 */
@Mapper
public interface VisitorMapper {

    /**
     * 添加无图片的visitor
     * @param visitor
     */
    Integer insertVisitor(VisitorEntity visitor);

    /**
     * 通过姓名、手机号查id
     * @param visitorName
     * @param visitorEmail
     * @return
     */
    @Select("select id from visitor where visitor_name = #{visitorName} and visitor_email = #{visitorEmail}")
    Integer getIdByNameAndEmail(String visitorName, String visitorEmail);

    /**
     * 通过id查询姓名
     * @param visitorId
     * @return
     */
    @Select("select visitor_name from visitor where id = #{visitorId}")
    String getNameById(Integer visitorId);

    /**
     * 通过id查询，通过name模糊匹配
     * @param id
     * @param visitorName
     * @return
     */
    @Select("select visitor_name from visitor where id = #{id} and visitor_name like '%${visitorName}%'")
    String getNameByIdAndName(Integer id, String visitorName);

    /**
     * 获取访客手机号
     * @param visitorId
     * @return
     */
    @Select("select visitor_email from visitor where id = #{id}")
    String getPhoneById(Integer visitorId);
}
